tools/insn-fuzz: Avoid making use of static data
authorAndrew Cooper <andrew.cooper3@citrix.com>
Mon, 20 Mar 2017 18:33:59 +0000 (18:33 +0000)
committerAndrew Cooper <andrew.cooper3@citrix.com>
Thu, 6 Apr 2017 17:42:49 +0000 (18:42 +0100)
commitb163e550df2127b2bd1fbce682bed87e8d18d0dc
treef11608d82a35a85a19f97b5fc4b3500f970273f1
parent654740b4bd8dfb358a9cf6876e60b79395a1d1fb
tools/insn-fuzz: Avoid making use of static data

AFL has a measure of stability, where it passes the same corpus into the
fuzzing harness and observes whether the execution path changes from before.
Any instability in the fuzzing harness reduces its effectiveness, as an
observed crash may not reliably be caused by the original corpus.

In preparation to fix a stability bug, introduce struct fuzz_state, allocated
on the stack and passed around via struct x86_emulate_ctxt's data parameter.
Propagate ctxt into the helpers such as maybe_fail(), so the state can be
retrieved.

Move the previously-static data_{index,num} into struct fuzz_state.

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
Reviewed-by: Jan Beulich <jbeulich@suse.com>
tools/fuzz/x86_instruction_emulator/fuzz-emul.c